/*
This is an example script for a 2D point map graphic (heat map). Click the Execute button to apply and then execute this script. Upon each execution the heat map alters its appearance. Turn on animation to execute periodically. Note that typically a heat map graphic should be instantiated on a graph data layer and the graph should be set to autoscale during animation.
*/

/* Declarations */

double cos(double a);
double sin(double a);

@@class() PointMap:Object

@@method(public, class) (id)stored;
@@method(public, instance) (void)emptyData;
@@method(public, instance) (void)finalize;
@@method(public, instance) (unsigned)animationCount;
@@method(public, instance) (void) setGridXLength:(unsigned)xLength xMinimum:(double)xMinimum xMaximum:(double)xMaximum yLength:(unsigned)yLength yMinimum:(double)yMinimum yMaximum:(double)yMaximum;
@@method(public, instance) (void) appendValue:(double)aValue;
@@method(public, instance) (void)release;

@@end

/* Execution block */

{
id myPointMap;
int ix, iy;
double xValue, yValue, zValue;
unsigned animationCount;
double phiAngle;
double mod;

myPointMap = [PointMap stored];

animationCount = [myPointMap animationCount];

/*
Empty the data and then append new data.
*/

[myPointMap emptyData];

[myPointMap setGridXLength:50 xMinimum:0.0 xMaximum:10.0 yLength:50 yMinimum:0.0 yMaximum:10.0];

mod = 0.125 * (animationCount % 80);

if(mod > 5.0)
{
mod = 10.0 - mod;
}

for(iy = 0; iy < 50; iy++)
{
yValue = iy * 0.2;

for(ix = 0; ix < 50; ix++)
{
xValue = ix * 0.2;
zValue = 5.0 * cos(xValue) + mod * sin(yValue);
[myPointMap appendValue:zValue];

}
}


}
